package com.googlecode.jpocketmod.templates.pages;

import java.awt.Image;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
 *
 * @author David Sosby
 */
public class PocketModPage implements Serializable  {
	private String name="", description="", bgImgFilepath="", category="";
	private List<PageContent> dynamicContent = new Vector<PageContent>();
	
	public PocketModPage(String name)  {
		this.name = name;
	}

	public String getBgImgFilepath() {		return bgImgFilepath;	}
	public void setBgImgFilepath(String bgImgFilepath) {		this.bgImgFilepath = bgImgFilepath;	}
	public String getCategory() {		return category;	}
	public void setCategory(String category) {		this.category = category;	}
	public String getDescription() {		return description;	}
	public void setDescription(String description) {		this.description = description;	}
	public String getName() {		return name;	}
	
	public List<PageContent> getDynamicContent() {		return dynamicContent;	}
	public void setDynamicContent(List<PageContent> dynamicContent) {		this.dynamicContent = dynamicContent;	}

	//Return a Set of available options (implemented as List for possible future enhancement)
	public List<String> getAvailableOptions()  {
		List<String> availableOptions = new Vector<String>();
		
		Iterator<PageContent> itr = dynamicContent.iterator();
		while ( itr.hasNext() )  {
			Iterator<String> optionsItr = itr.next().getAvailableOptions().iterator();
			while ( optionsItr.hasNext() )  {
				String thisOption = optionsItr.next();
				if ( !availableOptions.contains(thisOption) )  availableOptions.add(thisOption);
			}
		}
		
		return availableOptions;
	}
	
	public Image getImage(Map<String,String> instanceOptions)  {
		//TODO: This will generate this page's image
		//		1) Create Image
		//		2) Draw background
		//		3) Sort dynamicContent by zorder
		//		4) For each dynamic content, send image and instanceOptions

		return null;
	}
}
